package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.Scanner;

class book
{
    String nameOfBook="";
    book(String name)
    {
        nameOfBook=name;
    }
}
class movie
{
    String NameOfMovie="";
    int year=0;
    String NameOfDirector="";
    int rating=0;
    movie(String name,int yr,String dir,int rat)
    {
        NameOfMovie=name;
        year=yr;
        NameOfDirector=dir;
        rating=rat;
    }
}
class customer
{
     String username="";
    String password="";
    customer(String uname, String pass)
    {
        username=uname;
        password=pass;
    }
}
public class ManageFunctionalities
{
    Scanner s;
    book[] books=new book[47];
    movie[] movies=new movie[15];
    customer[] persons=new customer[2];
    ManageFunctionalities()
    {
        books[0]=new book("1984");
        books[1]=new book("A Brave Refrain");
        books[2]=new book("Above And Below");
        books[3]=new book("Abraham Lincoln");
        books[4]=new book("Abraham Lincoln's Second Inaugural Address");
        books[5]=new book("Acceptance");
        books[6]=new book("Acon");
        books[7]=new book("Adam And Eve");
        books[8]=new book("Adventures With Bears");
        books[9]=new book("Advice To A Son");
        books[10]=new book("Alice And The Pigeon");
        books[11]=new book("All's Well!");
        books[12]=new book("Along The Way");
        books[13]=new book("14 An American Tragedy");
        books[14]=new book("Arms and the Man");
        books[15]=new book("Atlas Shrugged");
        books[16]=new book("Autobiography of Charles Darwin");
        books[17]=new book("Axe, The Drum, The Bowl, And The Diamond");
        books[18]=new book("Back to the Army Again");
        books[19]=new book("Bag of Dust");
        books[20]=new book("Bars of Iron");
        books[21]=new book("Beloved");
        books[22]=new book("Black Heart and White Heart");
        books[23]=new book("Book Of Death");
        books[24]=new book("Brave New World");
        books[25]=new book("Catch-22");
        books[26]=new book("Gone With the Wind");
        books[27]=new book("Invisible Man");
        books[28]=new book("Lolita");
        books[29]=new book("Midnight’s Children");
        books[30]=new book("My Antonia");
        books[31]=new book("On the Road");
        books[32]=new book("Slaughterhouse-5");
        books[33]=new book("The Catcher in the Rye");
        books[34]=new book("The Great Gatsby");
        books[35]=new book("The Sound and The Fury");
        books[36]=new book("The Grapes of Wrath");
        books[37]=new book("The Sun Also Rises");
        books[38]=new book("The Adventures of Huckleberry Finn");
        books[39]=new book("The Heart is A Lonely Hunter");
        books[40]=new book("The Hitchhiker’s Guide to the Galaxy");
        books[41]=new book("The Tropic of Cancer");
        books[42]=new book("Their Eyes Were Watching God");
        books[43]=new book("To Kill a Mockingbird");
        books[44]=new book("To the Lighthouse");
        books[45]=new book("Ulysses");
        books[46]=new book("Which was the Foolishest?");

        movies[0]=new movie("Satyagraha",2013,"Prakash Zha",6);
        movies[1]=new movie("Agneepath",2012,"Karan Malhotra",7);
        movies[2]=new movie("ZNMD",2011,"Zoya Akhtar",8);
        movies[3]=new movie("Raajneeti",2010,"Prakash Zha",9);
        movies[4]=new movie("3 Idiots",2009,"Rajkumar Hirani",9);
        movies[5]=new movie("Jodhaa Akbar",2008,"Ashutosh Gowariker",8);
        movies[6]=new movie("Chak De! India",2007,"Shimit Amin",7);
        movies[7]=new movie( "Fanaa",2006,"Kunal Kohli",6);
        movies[8]=new movie( "Black",2005,"Sanjay Leela Bhansali",7);
        movies[9]=new movie( "Dhoom",2004,"Sanjay Gadhvi",8);
        movies[10]=new movie( "Kal Ho Naa Ho",2003,"Nikhil Advani",8);
        movies[11]=new movie( "Deewangee",2002,"Anees Bazmee",6);
        movies[12]=new movie("Lagaan",2001,"Ashutosh Gowariker",8);
        movies[13]=new movie( "Pukar",2000,"Rajkumar Santoshi",7);
        movies[14]=new movie( "Taal",1999,"Subhash Ghai",7);

        persons[0]=new customer("111-1111","patankar30");
        persons[1]=new customer("111-1112","sawant12");
    }

    public void ViewListOfBooks()
    {
        System.out.println("List of all books:");
        int loopVariable=0;
        while(loopVariable<books.length)
        {
            System.out.println(books[loopVariable].nameOfBook);
            loopVariable++;
        }
    }
        public void ReserveBook()
        {
            System.out.println("Which book do you want to reserve for your collection?");
            s=new Scanner(System.in);
            String NameOfBook=s.next();
            int loopVariable=0;
            while(loopVariable<books.length)
            {
                String BookFromLibrary=books[loopVariable].nameOfBook;
                if(BookFromLibrary.compareToIgnoreCase(NameOfBook)==0)
                {
                    System.out.println("Thank You! Enjoy the book");
                    break;
                }
                else
                    loopVariable++;
            }
            if(loopVariable==books.length)
                System.out.println("Sorry we don't have that book yet");
        }

    public void ViewListOfMovies()
    {

        int loopVariable=0;
        System.out.printf("%1s  %30s   %-20s   %-20s%n", "Movies", "Year", "Director", "Rating");
        while(loopVariable<15)
        {
           System.out.printf("%1s  %30s   %-20s   %-20s%n", movies[loopVariable].NameOfMovie, movies[loopVariable].year,movies[loopVariable].NameOfDirector,movies[loopVariable].rating);
           loopVariable++;
        }
    }

    public boolean checkAuthentication(String username, String password)
    {
        if(username.equals(persons[0].username)&&password.equals(persons[0].password))
            return true;
        else if(username.equals(persons[1].username)&&password.equals(persons[1].password))
            return true;
        else return false;
    }
}

